Golang : How to force compile or remove object files first before rebuild?
Problem :
You want to use rebuild or refresh your Golang program every time there is a change on any of the source files in your project. Basically, you want to remove the .a
(object) files "first" in the pkg
directory in your workspace each time when there is a rebuild. How to do that ?
Solutions :
In the go build
command, there is a -a
flag that you can use to refresh/rebuild or recompile everything packages that are already up-to-date.
For example :
>go build -a program-name
or you can issue the command
>go clean
first before executing go build
See also : Golang : Build and compile multiple source files
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+7.7k Golang : Randomize letters from a string example
+18.2k Unmarshal/Load CSV record into struct in Go
+16.3k Golang : Gzip file example
+17.2k Golang : Qt image viewer example
+5.3k Swift : Get substring with rangeOfString() function example
+18.1k Golang : Set, Get and List environment variables
+7k Golang : Scanf function weird error in Windows
+8.6k Golang : Get SPF and DMARC from email headers to fight spam
+8.1k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+6k PHP : Proper way to get UTF-8 character or string length
+27.6k Golang : Connect to database (MySQL/MariaDB) server
+5.2k Unix/Linux : How to find out the hard disk size?